package com.awifi.demo.byteUtil;

import com.awifi.demo.conf.KafkaConsumerConfig;

/**
 * @description: ToDo
 * @author: marin
 * @time: 2020/9/15 11:47
 */
public class ByteUtil {
    //byte 与 int 的相互转换
    public static byte intToByte(int x) {
        return (byte) x;
    }

    public static int byteToInt(byte b) {
        //Java 总是把 byte 当做有符处理；我们可以通过将其和 0xFF 进行二进制与得到它的无符值
        return b & 0xFF;
    }

    public static void main(String[] args) {
        int i = 234;
        System.out.println(intToByte(i));
        System.out.println(byteToInt(intToByte(i)));

    }
}
